assert(arg[1],"no tlp file")
local file = io.open(arg[1]);
assert(file,"open file error");

for l in file:lines() do
    local code,ch = l:match("(%x%x%x%x)%s*([^%s]+)");
    --print(l);
    if(ch)then
        --print(ch)
        ch = ch:gsub("*","");
        local c1 = code:sub(1,2);
        local c2 = code:sub(3);
        if(ch:byte(1)>=0xa1 and ch:byte(2)>=0xa1)then
        --int Y = c2;
        --int X = c1;
        --int off = ((Y-0xa1)*(0xF7-0xB0))+ X-0xB0;
        print(
            string.format("setch(0x%x,0x%x,0x%s,0x%s)",
            ch:byte(1),ch:byte(2),c1,c2
        ));
        end
    end
end


